package tech.aistar.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tech.aistar.pojo.Cart;

import java.util.List;

/**
 * 本来用来演示: 购物车
 *
 * @author success
 * @date 2025/3/5 08:56:14
 */
public interface CartMapper {
    /***
     * 根据用户id来查询购物车
     * @param userId
     * @return
     */
    @Select("select * from t_cart where user_id=#{value}")
    List<Cart> findByUser(Integer userId);

    @Delete("delete from t_cart where id=#{cartId} and user_id=#{userId}")
    int delCart(@Param("cartId") Integer cartId,@Param("userId") Integer userId);

    List<Cart> findLikeName(@Param("name") String name,@Param("userId") Integer userId);
}
